import React, { Component } from 'react'
import Footer from '../components/Footer'
import querystring from 'querystring'

class Child2 extends Component {
  constructor(props) {
    super(props);

    this.state = {
      // 对于可选路由参数设置默认值
      id: this.props.match.params.id || 100
    }
  }


  render() {
    // query
    console.log(querystring.parse(this.props.location.search.slice(1)))
    // params
    console.log(this.props.match.params)
    // 给params可选参数加默认值
    console.log(this.state.id);
    // state 隐式传递 编程式导航传过来
    console.log(this.props.location.state)
    return (
      <div>
        我是child2的组件
        <hr />
        <Footer />
      </div>
    )
  }
}

export default Child2